% Pattern recognition Computer project No 2
% pre I. Create the densities defined for each student.

% Oded Yechiel
P1 = 0.35;
P2 = 0.65;
a22 = 0.6;
a21 = 0.4;
a12 = 0.35;
a11 = 0.65;
% I = 1;
% j = 2;
% k = 3;
% m = 4;
state_in_rand = 247776455;
%Variant = 6;
Variant_1 = 4;
Variant_2 = 5;
%Bivar = I1;
Error_Rate = 0.08;

[M1,M2,M3,M4,Sigma1,Sigma2,Sigma3,Sigma4]=init_data;
M1(Variant_2,:) = [];
M1(Variant_1,:) = [];
M2(Variant_2,:) = [];
M2(Variant_1,:) = [];
M3(Variant_2,:) = [];
M3(Variant_1,:) = [];
M4(Variant_2,:) = [];
M4(Variant_1,:) = [];
M1 = 0.54*M1 + 0.46*M2;
M3 = 0.1*M3 + 0.9*M4;

Sigma1(Variant_2,:) = [];
Sigma1(Variant_1,:) = [];
Sigma1(:,Variant_2) = [];
Sigma1(:,Variant_1) = [];
Sigma2(Variant_2,:) = [];
Sigma2(Variant_1,:) = [];
Sigma2(:,Variant_2) = [];
Sigma2(:,Variant_1) = [];
Sigma3(Variant_2,:) = [];
Sigma3(Variant_1,:) = [];
Sigma3(:,Variant_2) = [];
Sigma3(:,Variant_1) = [];
Sigma4(Variant_2,:) = [];
Sigma4(Variant_1,:) = [];
Sigma4(:,Variant_2) = [];
Sigma4(:,Variant_1) = [];

d1 = density(6,M1,Sigma1,a11);
d2 = density(6,M2,Sigma2,a12);
d3 = density(6,M3,Sigma3,a21);
d4 = density(6,M4,Sigma4,a22);

w1 = classi(d1,d2,P1);
w2 = classi(d3,d4,P2);
clearvars -except w1 w2; close all;

% w1_15 = w1.magnify_class(15);
% w2_15 = w2.magnify_class(15);
% clearvars -except w1 w2 w1_15 w2_15